import os
from os.path import join,getsize


def getdirsize(dir):
    size = 0
    for root, dirs, files in os.walk(dir):
        size += sum([getsize(join(root, name)) for name in files])
    return size

if __name__ == '__main__':
    path = '/Users/shenyuwen/Documents/资料/测试学习/训练营/笔记'
    print('文件夹大小为%.2fMB' % (getdirsize(path)/1024/1024))